package both.map.mapModel.unitTests;

import junit.framework.Assert;

import org.junit.Test;
import org.junit.Before;

import both.map.mapModel.VisibilityCell;

public class VisibilityCellTest {
	VisibilityCell vc;
	
	@Before
	public void setUp() throws Exception {
		vc = new VisibilityCell();
	}

	@Test
	public void testSetVisibilityHasBeenSeenIsCurrentlyVisible() {
		Assert.assertFalse(vc.hasBeenSeen());
		Assert.assertFalse(vc.isCurrentlyVisible());
		vc.setVisibility(true, false);
		Assert.assertTrue(vc.hasBeenSeen());
		Assert.assertFalse(vc.isCurrentlyVisible());
		vc.setVisibility(false, true);
		Assert.assertFalse(vc.hasBeenSeen());
		Assert.assertTrue(vc.isCurrentlyVisible());
		vc.setVisibility(true, true);
		Assert.assertTrue(vc.hasBeenSeen());
		Assert.assertTrue(vc.isCurrentlyVisible());
	}

	@Test
	public void testUpdate() {
		VisibilityCell serVC = new VisibilityCell();
		VisibilityCell update = serVC.grabUpdate();
		Assert.assertNull(update);
		VisibilityCell cliVC = new VisibilityCell();
		
		cliVC.applyUpdate(update);
		Assert.assertFalse(cliVC.hasBeenSeen());
		Assert.assertFalse(cliVC.isCurrentlyVisible());
		
		serVC.setVisibility(true,true);
		
		update = serVC.grabUpdate();
		Assert.assertNotNull(update);
		
		cliVC.applyUpdate(update);
		Assert.assertTrue(cliVC.hasBeenSeen());
		Assert.assertTrue(cliVC.isCurrentlyVisible());
		
		update = serVC.grabUpdate();
		Assert.assertNull(update);
		
		cliVC.applyUpdate(update);
		Assert.assertTrue(cliVC.hasBeenSeen());
		Assert.assertTrue(cliVC.isCurrentlyVisible());
	}

}
